package com.cy1;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author CY
 * @date 2022/11/02 10:19
 **/
class Student {
    private String name;
    private int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

public class Test {

    public static void main(String[] args) {
//        int[] arr = {1, 4, 5};
//        List<Integer> collect = Arrays.stream(arr).filter(i -> i >= 3).boxed().collect(Collectors.toList());
//        System.out.println(Collections.min(collect, (o1, o2) -> o2 - o1));
        Student[] students = {new Student("chenyong", 21), new Student("yuanxiang", 21)};
        Arrays.stream(students).map(s->s.getName()).forEach(s-> System.out.println(s));



    }


}
